<?php
/**
 * Created by PhpStorm
 * User: hon(陈烁临) qq: 2275604210
 * Date: 2022/1/11
 * Time: 2:49 下午
 */

namespace App\Http\Controllers;


use App\Services\ProductService;

class ProductController extends Controller
{
    /**
     * Notes: 添加商品
     * User: hon(陈烁临) qq: 2275604210
     * Date: 2022/1/11
     * Time: 4:41 下午
     * @param ProductService $productService
     * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\Response
     * @throws \Exception
     */
    public function add( ProductService $productService)
    {
        $this->validateRequest(request(),[
            'name' => 'required|string'
        ],['name.required'=>'名称不能为空']);
        $product = $productService->add(request()->all());
        return $this->respSuccess($product,'创建成功');
    }

    public function skus($id,ProductService $productService)
    {
        return $this->respSuccess($productService->getSkus($id),'创建成功');
    }
}
